package com.wzs.rpc.protocol;

import lombok.Getter;

@Getter
public enum ProtocolMessageTypeEnum {
    REQUEST(0),
    RESPONSE(1),
    HEART_BEAT(2),
    OTHERS(3);
    private int code;
    ProtocolMessageTypeEnum(int code) {
        this.code = code;
    }

    /**
     * 根据code获取枚举
     */
    public static ProtocolMessageTypeEnum getEnumByValue(int code) {
        for (ProtocolMessageTypeEnum protocolMessageTypeEnum : ProtocolMessageTypeEnum.values()) {
            if (protocolMessageTypeEnum.getCode()==code) {
                return protocolMessageTypeEnum;
            }
        }
        return null;
    }
}
